/*
 * @Author: 李超越 1509572300@qq.com
 * @Date: 2024-09-07 11:52:55
 * @LastEditors: 李超越 1509572300@qq.com
 * @LastEditTime: 2024-09-17 16:31:57
 * @FilePath: /my_git/lesson32_socket/Main.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "UdpServer.hpp"
#include "InetAddr.hpp"
#include "MessageRoute.hpp"


using namespace dict_ns;

void Usage(std::string proc)
{
    std::cout << "Usage:\n\t" << proc << " local_port\n" << std::endl;
}

// ./udpserver port
// 云服务器的port默认都是禁止访问的。云服务器放开端口8080 ~ 8085
int main(int argc, char *argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERROR);
    }
    EnableScreen();
    // std::string ip = argv[1]; // TODO
    // 定义翻译模块
    // Dict dict;

    MessageRoute message;

    // 网络部分
    uint16_t port = std::stoi(argv[1]);
    std::unique_ptr<UdpServer> usvr = std::make_unique<UdpServer>(port, std::bind(&MessageRoute::Route, &message, 
                                    std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); // C++14
    usvr->InitServer();
    usvr->Start();

    return 0;
}